package com.yanfan.modbus.model;

import com.yanfan.modbus.ModbusUtils;
import com.yanfan.modbus.frame.abs.ModbusFrame;
import io.netty.buffer.ByteBuf;

/**
 * @author oliver foo
 * @description
 * @date 2022/3/16 8:28
 */
public class ModbusRtuMessage extends ModbusMessage {
    public ModbusRtuMessage(ModbusFrame modbusFrame) {
        super(modbusFrame);
    }


    @Override
    public void getMessageData(ByteBuf buf) {
        // Write the particular message.
        modbusFrame.write(buf);

        // Write the CRC
        buf.writeShort(ModbusUtils.calculateCRC(modbusFrame));
        // Return the data.
    }

}
